package leetcode.code0824;

import java.util.Iterator;

import leetcode.IDebug;

public class Solution implements IDebug {

	public String toGoatLatin(String sentence) {
		String[] words = sentence.split(" ");
		StringBuffer ans = new StringBuffer();
		int p = 1;
		for (String word : words) {
			ans.append(miemie(word, p++)).append(" ");
		}
		return ans.substring(0, ans.length() - 1);
	}

	private String miemie(String word, int index) {
		StringBuffer ans = new StringBuffer();
		char c = 1;
		if (isVowel(c = word.charAt(0))) {
			ans.append(word);
		} else {
			ans.append(word.substring(1)).append(c);
		}
		ans.append("ma");
		while (index > 0) {
			ans.append('a');
			index--;
		}
		return ans.toString();
	}

	private boolean isVowel(char c) {
		return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O'
				|| c == 'U';
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
